package com.wry.spring.extension;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * <h1>  </h1>
 *
 * @author wry
 * @since 2025.04.06
 */
@Configuration
public class FilterConfig {

    @Bean
    public FilterRegistrationBean<MyFilter1> registrationMyFilter1() {
        FilterRegistrationBean<MyFilter1> filterRegistrationBean = new FilterRegistrationBean<>(new MyFilter1());
        filterRegistrationBean.addUrlPatterns("/*");
        filterRegistrationBean.setOrder(2);
        return filterRegistrationBean;
    }

    @Bean
    public FilterRegistrationBean<MyFilter2> registrationMyFilter2() {
        FilterRegistrationBean<MyFilter2> filterRegistrationBean = new FilterRegistrationBean<>(new MyFilter2());
        filterRegistrationBean.addUrlPatterns("/*");
        filterRegistrationBean.setOrder(1);
        return filterRegistrationBean;
    }

    @Bean
    public FilterRegistrationBean<MyFilterLogin> registrationMyFilterLogin() {
        FilterRegistrationBean<MyFilterLogin> filterRegistrationBean = new FilterRegistrationBean<>(new MyFilterLogin());
        filterRegistrationBean.addUrlPatterns("/test/login");
        filterRegistrationBean.setOrder(0);
        return filterRegistrationBean;
    }
}
